package com.cxl.bill.server.service;

import com.cxl.bill.server.db.bean.User;
import com.cxl.bill.server.db.dao.UserDao;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    private final UserDao userDao;

    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    public int insert(User user){
        return userDao.insert(user);
    }

    /**
     * 根据用户名查询用户信息
     * @param userName 用户名
     * @return 用户对象{com.cxl.bill.server.db.bean.User}
     */
    public User findByUserName(String userName){
        return userDao.selectByUserName(userName);
    }

    /**
     * 根据Id查询
     * @param id 用户id
     * @return 用户对象{com.cxl.bill.server.db.bean.User}
     */
    public User findById(Long id){
        return userDao.selectByPrimaryKey(id);
    }
}
